﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;
using BCDataCenter;

public partial class WebMaster_Controls_MenuCatalogue : System.Web.UI.UserControl
{
    ClassExecute.ClassExecute dt;
    static string error = "";
    string str = BCDataCenter.Configuration.CurrentConnectionString;
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            if (Session["username"] == null || Session["Sitecode"] == null)
            {
                Response.Redirect(Globals.ApplicationPath + "Default.aspx");
            }
            else
            {
                if (Request.QueryString["MenuID"] == null)
                {
                    BindToRepeater("QTHT", Session["username"].ToString());
                    uscTitleForm1.Messeage = "QUẢN TRỊ HỆ THỐNG";
                }
                else
                {
                    BindToRepeater(Request.QueryString["MenuID"].ToString(), Session["username"].ToString());
                    if (Request.QueryString["MenuID"].ToString() == "QTHT")
                    {
                        uscTitleForm1.Messeage = "QUẢN TRỊ HỆ THỐNG";
                    }
                    else if (Request.QueryString["MenuID"].ToString() == "DLN")
                    {
                        uscTitleForm1.Messeage = "DỮ LIỆU NỀN";
                    }
                    else if (Request.QueryString["MenuID"].ToString() == "XNH")
                    {
                        uscTitleForm1.Messeage = "XUẤT NHẬP HÀNG";
                    }
                    else if (Request.QueryString["MenuID"].ToString() == "ICT")
                    {
                        uscTitleForm1.Messeage = "IN CHỨNG TỪ";
                    }
                    else if (Request.QueryString["MenuID"].ToString() == "CNV")
                    {
                        uscTitleForm1.Messeage = "CHỐT NGHIỆP VỤ";
                    }
                    else if (Request.QueryString["MenuID"].ToString() == "BC")
                    {
                        uscTitleForm1.Messeage = "BÁO CÁO";
                    }
                    else if (Request.QueryString["MenuID"].ToString() == "LKDL")
                    {
                        uscTitleForm1.Messeage = "LIỆT KÊ DỮ LIỆU";
                    }
                    else if (Request.QueryString["MenuID"].ToString() == "TI")
                    {
                        uscTitleForm1.Messeage = "TIỆN ÍCH";
                    }
                }
            }
        }
        else
        {
            //BindToRepeater(Request.QueryString["MenuID"].ToString(), Session["username"].ToString());
        }
    }
   
    void BindToRepeater(string MenuID,string Username)
    {
        dt = new ClassExecute.ClassExecute();
        DataTable db = dt.Get_Data_DataTable(str, ref error, "[get_MenuCatalogue_User]", CommandType.StoredProcedure,
            new SqlParameter("@MenuID", MenuID),
            new SqlParameter("@UserName",Username));
        dtlMenuCatalogue.DataSource = db;
        dtlMenuCatalogue.DataBind();
    }
}
